<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- <script>
        function Person(name,age){//添加私有属性
           this.name=name;
           this.age=age;
        }
        Person.prototype.show=function(){//公有
            console.log("111");
        }
        Person.job="ceo";//静态

        let p=new Person("lili",18);
        console.log(p);
    </script> -->
    <script>
       class Person{
          constructor(name,age){//添加私有属性
            this.name=name;
            this.age=age;
            //this.num=100;//相当于
          }
          show(){//添加公有属性
            console.log("111");
          }
          num=100//添加私有属性
          static job="ceo"//添加静态
       }
       Person.prototype.n=200;//添加公有属性
       let p=new Person("lili",18);
       console.log(p);
       console.dir(Person);


      class Child extends Person{
        constructor(play,name,age){//在 constructor 必须要写super(),否则不能使用this
            super(name,age);//普通类不传参，是不会给私有属性赋值的
            //相当于
            //this.name=name;
            //this.age=age;
           this.play=play;
        }
        fn(){//constructor 不写，意味着自动执行super(),能使用this
            console.log(this.name);
        }
      }
      let c=new Child("篮球","Tom",40);
      console.log(c);
      c.fn();
    </script>  
</body>
</html>